package com.yyfax.pay.third.model.to.quickpay;

import org.apache.commons.lang3.StringUtils;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.yyfax.framework.exception.YYException;
import com.yyfax.framework.yyfax.enums.RspCodeEnum;
import com.yyfax.pay.third.model.to.quickpay.xml.IndAuthContent;
/**
 * 独立鉴权发送验证码请求参数
 * @author xiemh
 * @date 2017-04-12 15:19:41
 * @since v1.0.0
 */
@SuppressWarnings("serial")
public class SendAuthenticationVerifyCodeQuickPayParams extends BaseQuickPayParams {
	private String version = "1.0";

	@XStreamAlias("indAuthContent")
	private IndAuthContent indAuthContent;

	public IndAuthContent getIndAuthContent() {
		return indAuthContent;
	}

	public void setIndAuthContent(IndAuthContent indAuthContent) {
		this.indAuthContent = indAuthContent;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	/**
	 * 通过xml生成实体类
	 * 
	 * @author xiemh
	 * @date 2017-04-12 14:51:24
	 * @since v1.0.0
	 * @param xml
	 * @return
	 */
	public static SendAuthenticationVerifyCodeQuickPayParams fromXml(String xml)  throws Exception{
		return (SendAuthenticationVerifyCodeQuickPayParams) fromXml(xml, SendAuthenticationVerifyCodeQuickPayParams.class);
	}

	@Override
	public boolean validate() throws Exception {
	
		if(StringUtils.isBlank(indAuthContent.getCustomerId())){
			throw new YYException(RspCodeEnum.COMMON_ERROR_PARAMETER_REQUIRED, "customerId/userId");
		}
		if(StringUtils.isBlank(indAuthContent.getExternalRefNumber())){
			throw new YYException(RspCodeEnum.COMMON_ERROR_PARAMETER_REQUIRED, "externalRefNumber/orderId");
		}
		if(StringUtils.isBlank(indAuthContent.getCardHolderId())){
			throw new YYException(RspCodeEnum.COMMON_ERROR_PARAMETER_REQUIRED, "cardHolderId/idNo");
		}
		return true;
	}

}
